/*
 * @file    multi_num.cpp
 * @author  edward <libo@tencent.com>
 * @date    2013-04-05
 * @brief   
 * */

#include <iostream>

void multi_num(int a[], int out[], int n) {
    int left = 1;
    int right = 1;
    for(int j = 0; j < n; ++j) {
        out[j] = 1;
    }
    for(int i = 0; i < n; ++i) {
        out[i] *= left;
        out[n - 1 - i] *= right;
        left *= a[i];
        right *= a[n - 1 - i];
    }
}

int main() {
    int tmp[] = {4, 3, 2, 1, 2};
    int out[5];
    multi_num(tmp, out, 5);
    for(int i = 0; i < 5; i++) {
        std::cout << out[i] << std::endl;
    }
}
